{extend name="public:base"}

{block name="right"}

<a href="{:Url('admin/ruleinfo')}" class="btn btn-success">添加分组</a>

{/block}

{block name="main"}
<form role="form">
    <div class="row">
        <div class="col-sm-3 col-xs-12 ">
            <div class="form-group">
                <div class="input-group">
                    <span class="input-group-addon">开始时间:</span>
                    <input type="date" name="start" class="form-control" value="{:input('start')}">
                </div>
            </div>
        </div>
        <div class="col-sm-3 col-xs-12 ">
            <div class="form-group">
                <div class="input-group">
                    <span class="input-group-addon">结束时间:</span>
                    <input type="date" name="end" class="form-control" value="{:input('end')}">
                </div>
            </div>
        </div>
        <div class="col-sm-3 col-xs-12 ">
            <div class="form-group">
                <div class="input-group">
                    <div class="btn-group">
                        <button type="submit" class="btn btn-success" title="立即搜索"><i class="fa fa-fw fa-search"></i></button>
                        {if condition="(input('get.start') gt '') OR (input('get.end') gt '')"}
                        <a href="{:Url('admin/rolelist')}" class="btn btn-default" title="查看全部"><i class="fa fa-close"></i></a>
                        {/if}
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
<table class="table table-bordered table-hover">
    <tbody>
    <tr>
      <th id="all" data-type="hide">展开全部</th>
      <th>菜单名称</th>
      <th>添加时间</th>
      <th>状态</th>
      <th>操作</th>
    </tr>
    {foreach $list as $v}
    <tr style="font-weight:700;" class="parented">
      <td class="add" data-id="{$v['id']}" data-type="hide">+</td>
      <td>{$v['name']}</td>
      <td>{$v['addtime']}</td>
      <td>
        {if condition="$v['status'] eq '1'"}
          <span class="label label-success">正常</span>
        {elseif condition="$v['status'] eq '0'" /}
          <span class="label label-danger">禁用</span>
        {/if}
      </td>
      <td>
          <div class="btn-group" role="group">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              操作
              <span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
              <li><a href="{:Url('admin/roleinfo',array('id'=>$v['id']))}">修改</a></li>
              {if condition="$v['status'] eq '1'"}
                <li><a href="javascript:setstatus(location.href,{$v['id']},'0')">禁用</a></li>
              {elseif condition="$v['status'] eq '0'"/} 
                <li><a href="javascript:setstatus(location.href,{$v['id']},'1')">启用</a></li>
              {/if}            
              <li><a href="javascript:setstatus(location.href,{$v['id']},'-1',1)">删除</a></li>
            </ul>
          </div>
        
      </td>
    </tr>
      {foreach $v['menu'] as $vo}
        <tr style="font-size:13px;color:#7D7D7D;display:none;" class="submenu data-id-{$v['id']}">
          <td></td>
          <td> -- {$vo['name']}</td>
          <td>{$vo['addtime']|stringtime}</td>
          <td>
            {if condition="$vo['status'] eq '1'"}
              <span class="label label-success">正常</span>
            {elseif condition="$vo['status'] eq '0'" /}
              <span class="label label-danger">禁用</span>
            {/if}
          </td>
          <td>
              <div class="btn-group" role="group">
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  操作
                  <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                  <li><a href="{:Url('admin/roleinfo',array('id'=>$vo['id']))}">修改</a></li>
                  {if condition="$vo['status'] eq '1'"}
                    <li><a href="javascript:setstatus('{:Url('admin/rulelist')}',{$vo['id']},'0')">禁用</a></li>
                  {elseif condition="$vo['status'] eq '0'"/} 
                    <li><a href="javascript:setstatus('{:Url('admin/rulelist')}',{$vo['id']},'1')">启用</a></li>
                  {/if}            
                  <li><a href="javascript:setstatus('{:Url('admin/rulelist')}',{$vo['id']},'-1',1)">删除</a></li>
                </ul>
              </div>
            
          </td>
        </tr>
      {/foreach}
    {/foreach}
  </tbody>
</table>
<script type="text/javascript">
    $(".add").click(function(){
        var type=$(this).attr("data-type");
        var id=$(this).attr("data-id");
        if(type=="hide"){
          $(this).text("-");
          
          $(".data-id-"+id).show();
          $(this).attr("data-type","show");
        }else{
          $(this).text("+");
          $(".data-id-"+id).hide();
          $(this).attr("data-type","hide");
        }
       
    });
    $("#all").click(function(){
        var type=$(this).attr("data-type");
       
        if(type=="hide"){
          $(".parented").text("+");
          $(".submenu").show();
          $(this).text("隐藏全部");
          $(this).attr("data-type","show");
        }else{
          $(".parented").text("+");
          $(".submenu").hide();
          $(this).text("展开全部");
          $(this).attr("data-type","hide");
        }
       
    });
</script>

{/block}
{block name="foot"}{$page}{/block}